package com.a_baseTest.java8Stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class TestStreamFilter {

    public static void sorted() {

        List<Integer> list = Arrays.asList(5, 4, 3, 2, 7, 1, 6, 9, 8);
        //过滤出大于5的数值
        List<Integer> filterList = list.stream().filter(x -> x == 5).collect(Collectors.toList());

        System.out.println("原始数组:" + list);
        System.out.println("过滤数组:" + filterList);

//        System.out.println();

//        List<Person> personList = new ArrayList<>();
//        personList.add(new Person("张三", 16, 181));
//        personList.add(new Person("李四", 17, 180));
//        personList.add(new Person("王五", 16, 179));
//        personList.add(new Person("张明", 18, 180));
//        personList.add(new Person("李威", 16, 190));
//        personList.add(new Person("王鹏", 15, 188));
//        personList.add(new Person("王莉", 17, 177));
//        personList.add(new Person("王鸥", 19, 180));
//
//        //年龄18岁及以上，身高180的人
//        List<Person> filterPList = personList.stream().filter(s -> s.getAge() >= 18 && s.getHeight() == 180).collect(Collectors.toList());
//
//        printPerson(filterPList);
    }

    public static void main(String[] args) {
        sorted();
    }



}
